function newMod(name)
	local modTable = {}
	if type(_G[name]) == "table" then
		print("mod_"..name.." has already been initiated.")
	elseif _G[name] then
		print (name.." is already initialized as a "..type(_G[name]))
	end
	--Init the modTable
	modTable.name = name
	modTable.privilege = {}
	modTable.acts = {}
	modTable.adms = {}
	modTable.typ  = {}
	modTable.var  = function(n, val, typ)
						if (type(n) == "string" and val ~= nil) then
							modTable[n] = val
							if not typ == "cvar" then typ = "svar" end
							modTable.typ[n] = typ
						end
					end
	modTable.setvar  = function(n, val, c)
						if c == nil then c = true end
						if (type(n) == "string" and val ~= nil) then
							modTable[n] = val
							if c then
								msg("Server svar \""..name.."_"..n.."\" changed to \""..val.."\"")
							end
							modTable.typ[n] = typ
						end
					end
	--Modifying the Global table
	if (type(name) == "string") then
		_G[name] = modTable
	end

	return modTable
end

function toMod(name)
	for g, v in pairs(_G) do
		if type(v) == "function" then
			local n = {}
			for word in string.gmatch(g, "%w+") do
				table.insert(n, word)
			end
			if n[1] == "hook" and n[3] == name then
				addhook(n[2], g)
			end
		end
	end
	return name, _G[name]
end

function mod_init(file)
	if (file == nil or type(file) ~= "string") then file = conf_dir.."mods.cfg" else file = conf_dir..file end
    for line in io.lines(file) do
		local f = loadfile(mods_dir..line..".lua")
		if type(f) =="function" then
			f = toMod(f())
			if type(f) == "table" then
				if type(f[2])=="table" then
					local name = f[1]
					--print("asdf")
					for k,v in pairs(f[2].privilege) do
						tempPriv = {toString = v}
						for i,word in ipairs(adminhierarchy(v)) do
							tempPriv[word] = word
						end
						cmd_priv[k] = tempPriv
					end
				end
			end
		end
	end
	acts = {}
	acts.default = function(p, typ, cmd) msg2(p, "Error: Command Does Not Exist: "..typ) end
	admacts = {}
	admacts.default = function(p, typ, cmd) msg2(p, "Error: Admin Command Does Not Exist: "..typ) end
	for g, v in pairs(_G) do
		if type(v) == "function" then
			local n = {}
			for word in string.gmatch(g, "%w+") do
				table.insert(n, word)
			end
			if n[1] == "act" then
				acts[n[2]] = v
			elseif n[1] == "adm" then
				admacts[n[2]] = v
				--cmd_priv[n[2]] = {[n[3]] = n[3]}
				tempPriv = {[n[3]] = n[3]}
				--print("a")
				--local x = adminhierarchy(n[3])
				--print(x)
				for i,word in ipairs(adminhierarchy(n[3])) do
					--print("a")
					tempPriv[word] = word
				end
				cmd_priv[n[2]] = tempPriv

			end
		end
	end
	action = switch(acts)
	admin_action = switch(admacts)
end
